[KYUUBI #7723][UTIL] Answer false from isClassLoadable when the class fails to link or initialize - #7724
Open
LuciferYang wants to merge 1 commit into
Conversation
… class fails to link or initialize
pan3793
approved these changes
Sep 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why are the changes needed?
Closes #7723.
ReflectUtils.isClassLoadablewrapped itsDynClassesprobe inscala.util.Try, which catches onlyNonFatal. The probe resolves the name withClass.forName(className, true, loader), so a class that is present but fails to link or initialize raises aLinkageError(NoClassDefFoundError,ExceptionInInitializerError) rather than aClassNotFoundException.LinkageErroris notNonFatal, so it escaped the probe and crashed the caller instead of answeringfalse.This replaces the
Trywith an explicittry/catchthat answersfalseonClassNotFoundExceptionandLinkageError. The two call sites (Loggingprobing the SLF4J bridge,JDBCMetadataStoreprobing the MySQL driver) read the result as a boolean and are only made safer.OutOfMemoryError/StackOverflowErrorareVirtualMachineError, notLinkageError, so they stay fatal exactly as they did underTry.How was this patch tested?
Added a
ReflectUtilsSuitecase that probes a top-level object whose static initializer throws, by its binary name, and assertsisClassLoadablereturnsfalse. Reverting the production change makes the suite abort as theExceptionInInitializerErrorescapes, which pins the regression.Module green on Zulu 17.0.18 (22/22), scalastyle 0 errors, spotless clean.
Was this patch assisted by generative AI tooling?
Assisted-by: Claude Opus 4.8